/*
 * Version 0.2 by Andreas Dier
 *      Edit because super class changed
 */
package ueb13.uebOrder;

import ueb13.htw.queue.Prioritizable;

/**
 *
 * @author Andreas Dier, Steffen Schuhmann
 * @version 0.2
 */
public class PriorityOrder extends Order implements Prioritizable{
    
    protected int orderPriority;
    
    public PriorityOrder(int orderPriority
            , int orderID, String client) throws OrderException {
        super(orderID,client);
        this.orderPriority = orderPriority;
    }
    
    @Override
    public String toString() {
        StringBuilder string = new StringBuilder();
        string.append(getPriority()).append(TAB)
            .append(getOrderID()).append(TAB).append(getClient());
        
        return string.toString();
    }
    
    public int compareIo(PriorityOrder t) {
        if(t instanceof PriorityOrder) {
            if(t.getPriority() == orderPriority)
                return 0;
            if(t.getPriority() > orderPriority)
                return -1;
            return 1;
        }
        
        return -1;
    }

    /**
     * @return the orderPriority
     */
    public int getPriority() {
        return orderPriority;
    }
    
    public void setPriority(int priority) {
        this.orderPriority = priority;
    }

}
